<?php

namespace app\common\model;

class WeixinExpress extends Base
{

    protected $deleteTime = "delete_time";

    /**
     * 获取用户快递剩余次数
     * @param string $openid
     * @return WeixinIntegral|array|int|mixed|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getUserExpressSurplus(string $openid = '')
    {
        //获取当前
        $integral = $this->field('sum(num) as num')
            ->where('openid', $openid)
            ->find();
        return $integral['num'] ?? 0;
    }
}